package com.ruoyi.swimming.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.swimming.domian.CourseCoach;
import com.ruoyi.swimming.mapper.CourseCoachMapper;
import com.ruoyi.swimming.service.ICourseCoachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 教练Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@Service
public class CourseCoachServiceImpl extends ServiceImpl<CourseCoachMapper, CourseCoach> implements ICourseCoachService
{
    @Autowired
    private CourseCoachMapper courseCoachMapper;

    /**
     * 查询教练
     * 
     * @param id 教练ID
     * @return 教练
     */
    @Override
    public CourseCoach selectCourseCoachById(Long id)
    {
        return courseCoachMapper.selectCourseCoachById(id);
    }

    /**
     * 查询教练列表
     * 
     * @param courseCoach 教练
     * @return 教练
     */
    @Override
    public List<CourseCoach> selectCourseCoachList(CourseCoach courseCoach)
    {
        return courseCoachMapper.selectCourseCoachList(courseCoach);
    }

    /**
     * 新增教练
     * 
     * @param courseCoach 教练
     * @return 结果
     */
    @Override
    public int insertCourseCoach(CourseCoach courseCoach)
    {
        courseCoach.setCreateTime(DateUtils.getNowDate());
        return courseCoachMapper.insert(courseCoach);
    }

    /**
     * 修改教练
     * 
     * @param courseCoach 教练
     * @return 结果
     */
    @Override
    public int updateCourseCoach(CourseCoach courseCoach)
    {
        courseCoach.setUpdateTime(DateUtils.getNowDate());
        return courseCoachMapper.updateById(courseCoach);
    }

    /**
     * 批量删除教练
     * 
     * @param ids 需要删除的教练ID
     * @return 结果
     */
    @Override
    public int deleteCourseCoachByIds(Long[] ids)
    {
        return courseCoachMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除教练信息
     * 
     * @param id 教练ID
     * @return 结果
     */
    @Override
    public int deleteCourseCoachById(Long id)
    {
        return courseCoachMapper.deleteById(id);
    }
}
